#include <iostream>
#include <vector>
using namespace std;

long envelope(vector<long>& answerlist,int a){
    if (a == 1) return 0;
    if (a == 2) return 1;
    if (answerlist[a] != 0) return answerlist[a];
    else return (a-1) * (envelope(answerlist,a-1)+envelope(answerlist,a-2));
}

int main(){
    cout << "请输入总人数：" ;
    int a; cin >> a;
    vector<long> result;
    for (int i = 0; i < a + 1; ++i){result.push_back(0);}
    long res = envelope(result,a);
    cout << "全错排的可能情况有" << res << "种" << endl;
    return 0;
}